<?php
function template_preprocess_mewdkp_player_node_view(&$vars){
	$class_names = variable_get('mewdkp_lookup_class', array());
	$race = variable_get('mewdkp_lookup_race', array());
	$player = $vars['player'];
	
	$vars['name'] = $player->field_mewdkp_player_name[0]['value'];
	
	// -- Class Icon
	$classnames = variable_get('mewdkp_lookup_class', array());	
	$path = drupal_get_path('module', 'mewdkp') . '/images/icons/';
	$vars['classicon'] = '/' . $path . 'IconLarge_' . str_replace(' ', '_', $classnames[$player->field_mewdkp_class[0]['value']]) . '.png';
	
	// -- Status
	$vars['status'] = $player->status;
	
	// -- Use class coloring
	if (variable_get('mewdkp_use_class_colors', TRUE)){
		$vars['class_coloring'] = str_replace(' ', '', strtolower($class_names[$player->field_mewdkp_class[0]['value']]));
	}
	
	// -- Class name	
	$vars['class'] = $class_names[$player->field_mewdkp_class[0]['value']];
	
	// -- Race name
	$vars['race'] = $race[$player->field_mewdkp_race[0]['value']];
	
	
	// -- Armory link
	$vars['armory'] = l(t('Armory'), 'http://' . variable_get('mewdkp_armory_region', 'www.wowarmory.com') . '/character-sheet.xml?r=' . variable_get('mewdkp_armory_realm', 'Sargeras') . '&n=' . $player->field_mewdkp_player_name[0]['value']);
	
	// -- DKP
	if (user_access('administer mewdkp')){		
		$vars['dkp'] = number_format($player->field_mewdkp_dkp_current[0]['value'], 2);
		$vars['dkp_earned'] = number_format($player->field_mewdkp_dkp_earned[0]['value'], 2);
		$vars['dkp_spent'] = number_format($player->field_mewdkp_dkp_spent[0]['value'], 2);
	} else {
		$vars['dkp'] = 'Hidden';
		$vars['dkp_earned'] = 'Hidden';
		$vars['dkp_spent'] = 'Hidden';
	}
}